package com.wangyadong.hobby.thread.lesson10withcocurrent;


import java.util.concurrent.*;

public class FutureDeadLock {

    private final ExecutorService exec = Executors.newFixedThreadPool(1);

    public class LoadFileTask implements Callable<String> {
        private final String fileName;

        public LoadFileTask(String fileName) {
            this.fileName = fileName;
        }

        public String call() throws Exception {
            // Here's where we would actually read the file
            return "";
        }
    }

    public String call() throws ExecutionException, InterruptedException {
        Future<String> header = exec.submit(new Callable<String>() {
            @Override
            public String call() throws Exception {
                return null;
            }
        });

        Future<String> body = exec.submit(new Callable<String>() {
            @Override
            public String call() throws Exception {
                return null;
            }
        });
        return header.get() + "" + body.get();
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureDeadLock deadLock = new FutureDeadLock();
        deadLock.call();
    }
}
